package supermarket;

import java.util.Scanner;

public class Shopping {
    public static void main(String[]args) {
        SuperMarket supermarket = new SuperMarket();
        supermarket.setMarketName("小明超市");
        Goods[] g = new Goods[3];
        for (int i = 0; i < g.length; i++) {
            g[i] = new Goods();
        }
        g[0].setGoodsName("手机");
        g[0].setGoodsNumber(1);
        g[0].setPrice(1360.2);

        g[1].setGoodsName("电脑");
        g[1].setGoodsNumber(2);
        g[1].setPrice(5760.2);

        g[2].setGoodsName("平板");
        g[2].setGoodsNumber(3);
        g[2].setPrice(960.5);
        supermarket.setGoodsList(g);
        Member[] m = new Member[2];
        for (int i = 0; i < m.length; i++) {
            m[i] = new Member();
        }
        m[0].setUserNumber("张三");
        m[0].setPassWorld("123456");

        m[1].setUserNumber("李四");
        m[1].setPassWorld("123456");
        supermarket.setMembers(m);
        System.out.println("--------欢迎来到" + supermarket.getMarketName() + "购物-------");
        boolean make = false;
        while (!make) {
            System.out.println("请输入用户名");
            Scanner sc = new Scanner(System.in);
            String userName;
            userName = sc.nextLine();
            System.out.println("请输入密码");
            String passWord = sc.nextLine();
            System.out.println(userName);
            Member[] members;
            members = supermarket.getMembers();
            for (int i = 0; i < members.length; i++) {
                Member member = supermarket.getMembers()[i];
                if (userName.equals(members[i].getUserNumber()) && passWord.equals(members[i].getPassWorld())) {
                    System.out.println("用户名在会员系统中");
                    make = true;
                    break;
                }
            }
            if (!make) {
                System.out.println("用户名或密码错误");
            }
        }
        System.out.println("-------------欢迎来到" + supermarket.getMarketName() + "购物---------");
        Goods[] goods = supermarket.getGoodsList();
        for (Goods good : goods) {
            System.out.println(good.getGoodsNumber() + "\t" + good.getGoodsName() + "\t" + good.getPrice());
        }
        System.out.println("--------------------------------------");
        System.out.println("请输入商品编号");
        Scanner sc = new Scanner(System.in);
        int index = sc.nextInt();
        System.out.println("请输入商品的数量");
        int count = sc.nextInt();
    }
}
